package com.ruoyi.teacher.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.TAssessment;
import com.ruoyi.teacher.service.ITAssessmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考核信息Controller
 * 
 * @author xiangzy
 * @date 2022-05-08
 */
@RestController
@RequestMapping("/teacher/assessment")
public class TAssessmentController extends BaseController
{
    @Autowired
    private ITAssessmentService tAssessmentService;

    /**
     * 查询考核信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:assessment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TAssessment tAssessment)
    {
        startPage();
        List<TAssessment> list = tAssessmentService.selectTAssessmentList(tAssessment);
        return getDataTable(list);
    }

    /**
     * 导出考核信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:assessment:export')")
    @Log(title = "考核信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TAssessment tAssessment)
    {
        List<TAssessment> list = tAssessmentService.selectTAssessmentList(tAssessment);
        ExcelUtil<TAssessment> util = new ExcelUtil<TAssessment>(TAssessment.class);
        return util.exportExcel(list, "assessment");
    }

    /**
     * 获取考核信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:assessment:query')")
    @GetMapping(value = "/{recordid}")
    public AjaxResult getInfo(@PathVariable("recordid") Long recordid)
    {
        return AjaxResult.success(tAssessmentService.selectTAssessmentById(recordid));
    }

    /**
     * 新增考核信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:assessment:add')")
    @Log(title = "考核信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAssessment tAssessment)
    {
        return toAjax(tAssessmentService.insertTAssessment(tAssessment));
    }

    /**
     * 修改考核信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:assessment:edit')")
    @Log(title = "考核信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAssessment tAssessment)
    {
        return toAjax(tAssessmentService.updateTAssessment(tAssessment));
    }

    /**
     * 删除考核信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:assessment:remove')")
    @Log(title = "考核信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordids}")
    public AjaxResult remove(@PathVariable Long[] recordids)
    {
        return toAjax(tAssessmentService.deleteTAssessmentByIds(recordids));
    }
}
